<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function fn(url) {
            return new Promise((res, rej) => {
                var xhr = new XMLHttpRequest()
                xhr.open('get', url)
                xhr.send()
                xhr.responseType = 'json'
                xhr.onload = () => {
                    res(xhr.response)
                }
                xhr.onerror =(e)=>{
                    rej(e)
                }
            })
        }
        fn('https://liu.zzgoodqc.cn/teas').then(val=>{
            console.log(val);
        })
        .catch(e =>{
            console.log(e);
        })
        fn('https://liu.zzgoodqc.cn/lyb/list').then(val=>{
            console.log(val);
        })
        .catch(e =>{
            console.log(e);
        })
        // 删除请求方式
        function fn(url) {
            return new Promise((res, rej) => {
                var xhr = new XMLHttpRequest()
                xhr.open('get', url)
                xhr.send()
                xhr.responseType = 'json'
                xhr.onload = () => {
                    res(xhr.response)
                }
                xhr.onerror =(e)=>{
                    rej(e)
                }
            })
        }
        fn('https://liu.zzgoodqc.cn/teas').then(val=>{
            console.log(val);
        })
        .catch(e =>{
            console.log(e);
        })
        fn('https://liu.zzgoodqc.cn/lyb/list').then(val=>{
            console.log(val);
        })
        .catch(e =>{
            console.log(e);
        })
    </script>
</body>

</html>